package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbVirusDevice;
import com.ruoyi.system.service.ITbVirusDeviceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * virus deviceController
 * 
 * @author SJQ
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/system/device")
public class TbVirusDeviceController extends BaseController
{
    @Autowired
    private ITbVirusDeviceService tbVirusDeviceService;

    /**
     * 查询virus device列表
     */
    @PreAuthorize("@ss.hasPermi('system:device:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVirusDevice tbVirusDevice)
    {
        startPage();
        List<TbVirusDevice> list = tbVirusDeviceService.selectTbVirusDeviceList(tbVirusDevice);
        return getDataTable(list);
    }

    /**
     * 导出virus device列表
     */
    @PreAuthorize("@ss.hasPermi('system:device:export')")
    @Log(title = "virus device", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbVirusDevice tbVirusDevice)
    {
        List<TbVirusDevice> list = tbVirusDeviceService.selectTbVirusDeviceList(tbVirusDevice);
        ExcelUtil<TbVirusDevice> util = new ExcelUtil<TbVirusDevice>(TbVirusDevice.class);
        util.exportExcel(response, list, "virus device数据");
    }

    /**
     * 获取virus device详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:device:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbVirusDeviceService.selectTbVirusDeviceById(id));
    }

    /**
     * 新增virus device
     */
    @PreAuthorize("@ss.hasPermi('system:device:add')")
    @Log(title = "virus device", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVirusDevice tbVirusDevice)
    {
        return toAjax(tbVirusDeviceService.insertTbVirusDevice(tbVirusDevice));
    }

    /**
     * 修改virus device
     */
    @PreAuthorize("@ss.hasPermi('system:device:edit')")
    @Log(title = "virus device", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVirusDevice tbVirusDevice)
    {
        return toAjax(tbVirusDeviceService.updateTbVirusDevice(tbVirusDevice));
    }

    /**
     * 删除virus device
     */
    @PreAuthorize("@ss.hasPermi('system:device:remove')")
    @Log(title = "virus device", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbVirusDeviceService.deleteTbVirusDeviceByIds(ids));
    }
}
